package main.controller.admin;

import main.RequestHelper;
import main.database.AccountHelper;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

@Controller
public class AdminPageController {
    @RequestMapping(value = "/admin")
    public String adminPage(ModelMap modelMap, HttpServletRequest request) {

        String uuid = RequestHelper.getUserUUIDFromRequest(request);
        boolean isAdmin = AccountHelper.isAdminFromUUID(uuid);

        if (isAdmin) {
            return "redirect:/fictionlist";
        } else {
            return "admin/adminLoginPage";
        }
    }
}
